#coding:utf-8

import hashlib
import time
from datetime import datetime,timedelta



class TokenHandler(object):

    def timeStamp(self,seconds=604800):

        expire = datetime.now() + timedelta(seconds=seconds)

        return time.mktime(time.localtime()),time.mktime(expire.timetuple())

    @classmethod
    def produceToken(cls,key):

        hash = hashlib.md5()

        content = "{}_{}".format(key,time.time())

        hash.update(bytes(content, encoding='utf=8'))

        return hash.hexdigest()


